package com.example.tool.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.tool.R;
import com.example.tool.bean.SelectBean;
import com.example.tool.dao.entity.Person;

import java.util.List;

/**
 * Created Date 2019/9/23
 *
 * @author liangkun
 * description：数据库适配器
 */
public class FavorMovieAdapter extends BaseQuickAdapter<SelectBean, BaseViewHolder> {
    private Context context;

    public FavorMovieAdapter(int layoutResId, @Nullable List<SelectBean> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }


    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(@NonNull BaseViewHolder helper, SelectBean item) {
        helper.setText(R.id.tv_item, item.getText()).linkify(R.id.tv_item);
        if (item.isSelected()) {
            helper.setBackgroundRes(R.id.tv_item, R.drawable.shape_red_corn);
        } else {
            helper.setBackgroundRes(R.id.tv_item, R.drawable.shape_gray_corn);
        }
    }

}
